package com.letao.controller;

import com.letao.common.pojo.EUDataGridResult;
import com.letao.common.pojo.LetaoResult;
import com.letao.pojo.TbItemParam;
import com.letao.service.ItemParamSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by ac on 2017/1/11.
 */
@Controller
@RequestMapping("/item/param")
public class ItemParamController {

    @Autowired
    private ItemParamSevice itemParamSevice;

    @RequestMapping("/query/itemcatid/{itemCatId}")
    @ResponseBody
    public LetaoResult getItemParam(@PathVariable Long itemCatId){
        return itemParamSevice.getItemParaByCid(itemCatId);
    }

    @RequestMapping("/list")
    @ResponseBody
    public EUDataGridResult getItemParamList(@RequestParam Integer page, @RequestParam Integer rows){
        return itemParamSevice.findItemParaList(page, rows);
    }

    @RequestMapping("/save/{cid}")
    @ResponseBody
    public LetaoResult saveItemPara(@PathVariable Long cid, @RequestParam String paramData){
        TbItemParam tbItemParam = new TbItemParam();
        tbItemParam.setItemCatId(cid);
        tbItemParam.setParamData(paramData);
        return itemParamSevice.insertItemPara(tbItemParam);
    }
}
